package cn.idanda.test.base;

import java.util.Date;
import java.util.List;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import cn.idanda.core.dao.UserDao;
import cn.idanda.core.entity.oa.User;
/**
 * 初始化系统测试
 * @author rain
 * @since 2015年9月13日 下午1:17:48
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:applicationContext.xml")
public class InitContext {
	@Autowired
	private UserDao uDao;
	@Test
	public void testFindUserById(){
	}
	
	@Test
	public void saveUser(){
		User user =new User();
		user.setCreateTime(new Date().toString());
		user.setEmail("1039895299@qq.com");
		user.setPassword("shabi");
		user.setUsername("jianghang");
		uDao.save(user);
	}
	@Test
	public void findAllUser(){
		List<User> users = (List<User>) uDao.findAll();
		for(User u : users){
			System.out.println(u.getUsername());
		}
	}
}
